package com.lc.luzhengtang.fragment;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lc.luzhengtang.R;
import com.lc.luzhengtang.adapter.IndexAdapter;
import com.lc.luzhengtang.banner.BannerLayout;
import com.lc.luzhengtang.divider.SimpleDividerItemDecoration;

import com.lc.luzhengtang.layoutmanager.FullyGridLayoutManager;
import com.lc.luzhengtang.marqueue.MarqueeView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/5/3.
 */

public class DecoctionFragment extends BaseFragment {
    @BindView(R.id.banner2)
    BannerLayout banner2;
    Unbinder unbinder;
    List<String> urls;


    @BindView(R.id.imageView3)
    ImageView imageView3;
    @BindView(R.id.marqueeView)
    MarqueeView marqueeView;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
 /*   @BindView(R.id.refreshLayout)
    SwipeRefreshLayout refreshLayout;*/

    List<String> mDatas;

    IndexAdapter mIndexAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //  return super.onCreateView(inflater, container, savedInstanceState);
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_decocation, null);

        unbinder = ButterKnife.bind(this, view);

        final List<String> urls = new ArrayList<>();
        urls.add("http://pic6.huitu.com/res/20130116/84481_20130116142820494200_1.jpg");
        urls.add("http://img13.poco.cn/mypoco/myphoto/20120828/15/55689209201208281549023849547194135_001.jpg");
        urls.add("http://img03.tooopen.com/images/20131111/sy_46708898917.jpg");
        urls.add("http://pic39.nipic.com/20140318/496038_202510516000_2.jpg");
        urls.add("http://file06.16sucai.com/2016/0324/7b07c97b5e653c45c37499236848d519.jpg");

        banner2.setViewUrls(urls);

        //添加监听事件
        banner2.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Toast.makeText(getActivity(), String.valueOf(position), Toast.LENGTH_SHORT).show();
            }
        });


        List<String> info = new ArrayList<>();
        info.add("1.能够适应多行长文本的Android TextView的例子");
        info.add("2.\"科比，！");
        info.add("3. GitHub帐号：zhangyuanchong");
        info.add("4.\"理解的也很简单，");
        info.add("5. 破解密钥");
        info.add("6. 实现了两种方式");
        marqueeView.startWithList(info);
        marqueeView.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
            @Override
            public void onItemClick(int position, TextView textView) {
                position = position + 1;
                Toast.makeText(getActivity(), "点击了" + position, Toast.LENGTH_SHORT).show();
            }
        });

        recyclerView.setLayoutManager(new FullyGridLayoutManager(getActivity(), 2));
        mDatas = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            mDatas.add("屌人" + i);
        }
    //    mIndexAdapter = new IndexAdapter(mDatas);
        Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.line_divider_index);
        recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getContext(), drawable, 2));
        recyclerView.setAdapter(mIndexAdapter);
        recyclerView.setNestedScrollingEnabled(false);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    @OnClick({ R.id.imageView3, R.id.marqueeView})
    public void onViewClicked(View view) {
        switch (view.getId()) {



            case R.id.imageView3:
                break;
            case R.id.marqueeView:
                break;

        }
    }


}
